package cn.wolfcode.crm.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.github.pagehelper.PageInfo;

import cn.wolfcode.crm.domain.Customer;
import cn.wolfcode.crm.query.CustomerQueryObject;
import cn.wolfcode.crm.service.ICustomerService;

@Controller
@RequestMapping("/customerPool")
public class CustomerPoolController {
	@Autowired
	private ICustomerService customerPoolService;

	@RequestMapping("/list")
	public String list(@ModelAttribute("qo") CustomerQueryObject qo, Model model) {
		//查询客户池
		qo.setStatus(1);
		PageInfo<Customer> pageInfo = customerPoolService.list(qo);
		model.addAttribute("pageInfo", pageInfo);
		return "customerPool/list";
	}

	@RequestMapping("/saveOrUpdate")
	public String saveOrUpdate(Customer entity) {
		customerPoolService.saveOrUpdate(entity);
		return "redirect:/customerPool/list.do";
	}
}
